package team.seekers.oj.codetest.enums;


import com.baomidou.mybatisplus.annotation.IEnum;
import lombok.Getter;

import java.util.Arrays;

@Getter
public enum CodeTestTypeEnum implements IEnum<Integer> {

    EASY(0, "入门"),
    FIGURE(1,  "图论"),
    DYNAMIC(2, "动态规划");

    private int type;
    private String name;

    @Override
    public Integer getValue() {
        return this.type;
    }

    CodeTestTypeEnum(int type,String name){
        this.type = type;
        this.name = name;
    }

    public static CodeTestTypeEnum getByType(int type) {
        return Arrays.stream(values()).filter(e -> e.getType() == type).findFirst().orElse(null);
    }

    public static CodeTestTypeEnum getByName(String name) {
        return Arrays.stream(values()).filter(e -> e.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
    }
}
